﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Default.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<AbstractSaaSTemplate.Domain.Models.Entities.Tenant>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"><%: Metadata.RootTenantListTenantsTitle %></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MetaDescription" runat="server"><%: Metadata.RootTenantListTenantsDescription%></asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MetaKeywords" runat="server"><%: Metadata.RootTenantListTenantsKeywords%></asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="H1Content" runat="server"><%: Metadata.RootTenantListTenantsTitle%></asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="InnerBodyClass" runat="server">root tenant list-tenants</asp:Content>

<asp:Content ID="Content6" ContentPlaceHolderID="MainContent" runat="server">

<%: Html.ActionLink(
    Expressions.CreateNew,
    "CreateOrEditTenant") %>

<table>
    <tr>
        <th class="administrator-member-id"><%: Expressions.AdministratorMember %></th>
        <th class="company-name"><%: Expressions.CompanyName %></th>
        <th class="web-site"><%: Expressions.Website %></th>
        <th class="confirmed-at"><%: Expressions.ConfirmedAt %></th>
        <th class="created-at"><%: Expressions.CreatedAt %></th>
        <th></th>
    	<th></th>
	</tr>
	
<% foreach (var item in this.Model) { %>
    <tr>
        <td>
            <%
       var tenantsAdministrators = this.ViewBag.TenantsAdministrators as Dictionary<AbstractSaaSTemplate.Domain.Models.Entities.Tenant, AbstractSaaSTemplate.Domain.Models.Entities.User>;
            if (tenantsAdministrators != null && tenantsAdministrators.ContainsKey(item)) {
                var administrator = tenantsAdministrators[item];
            %>
            <%: administrator.FirstName %>
            <%: administrator.LastName %>
            <% } else { %>
            (<%: Expressions.NotAvailable %>)
            <% } %>
        </td>
        <td>
            <%: item.CompanyName %>
            (<%: item.DisplayName %>)
        </td>
        <td><%: item.Website %></td>
        <td><%: string.Format("{0:g}", item.ConfirmedAt) %></td>
        <td><%: string.Format("{0:g}", item.CreatedAt) %></td>
        <td><%: Html.ActionLink(
			Expressions.Edit,
            "CreateOrEditTenant",
			new { id=item.Id }) %></td>
        <td><%: Ajax.ActionLink(
            Expressions.Invite,
            "ResendWelcomeMessage",
            new { tenantId = item.Id },
            new AjaxOptions() { HttpMethod = "POST" })%></td>
    </tr>  
<% } %>
</table>

</asp:Content>

<asp:Content ID="Content7" ContentPlaceHolderID="StylesReferences" runat="server">
</asp:Content>

<asp:Content ID="Content8" ContentPlaceHolderID="JavascriptReferences" runat="server">
</asp:Content>
